package com.rayboo.example.design.pattern.adapter.actual;

import java.util.Map;

/**
 * HttpManager
 *
 * @author ray
 */
public class HttpManager {

    public static final String DIVIDER = ",";
    public static final String CODE_SUCCESS = "0";
    public static final String CODE_FAILED = "1";
    public static final String CODE_ERROR = "-1";

    public static final String ID = "1024";

    public void queryUserNameById(Map<String, String> params, OnResponseListener listener) {
        if (params == null) {
            listener.onError(CODE_ERROR, "参数不能为空");
            return;
        }
        String id = params.get("id");
        if (ID.equals(id)) {
            listener.onResponse(CODE_SUCCESS + DIVIDER + "张三");
            return;
        }
        listener.onResponse(CODE_FAILED + DIVIDER + "未找到对应用户");
    }
}
